import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/public/public_untilController.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_refresh.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_search.dart';
import '../package_list/view.dart';
import 'logic.dart';

class PackageSearchPage extends StatefulWidget {
  const PackageSearchPage({Key? key}) : super(key: key);

  @override
  State<PackageSearchPage> createState() => _PackageSearchPageState();
}

class _PackageSearchPageState extends State<PackageSearchPage> {
  final PackageSearchLogic logic = Get.put(PackageSearchLogic());
  final HLRefreshController refreshController = HLRefreshController(initialRefresh: false);
  final HLUntilController untilController = HLUntilController();
  bool isOperate = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(
        navigationTitle: "包裹查询",
        backAction: () {
          Get.back(result: isOperate);
        },
        bottom: PreferredSize(
            preferredSize: Size(double.infinity, 50),
            child: MGSearch(
              hintText: "请输入收件人手机号或快递单号",
              onClick: (value) {
                if (untilController.actions != null) {
                  untilController.actions!(value);
                  refreshController.requestRefresh();
                }
              },
            )),
      ),
      body: PackageListPage(
          refreshController: refreshController,
          recallPackageAction: () {
            refreshController.requestRefresh();
            isOperate = true;
          },
          modifyPhoneAction: () {
            isOperate = true;
          }),
    );
  }

  @override
  void dispose() {
    Get.delete<PackageSearchLogic>();
    super.dispose();
  }
}
